import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class ContactsItem extends StatelessWidget {
  final VoidCallback onTap;
  final bool isSelect;
  final String title;
  final String amount;
  final bool isGet;
  final VoidCallback onClickStar;
  final bool isOverdue;
  final bool hasCreditBalance;
  final bool isLastItem;

  const ContactsItem(
      {Key key,
      this.onTap,
      this.isSelect,
      this.title,
      this.amount,
      this.isGet,
      this.onClickStar,
      this.isOverdue,
      this.hasCreditBalance = false,
      this.isLastItem = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PressedOpacityButton(
      onPressed: onTap,
      color: Colors.white,
      padding: EdgeInsets.symmetric(
        horizontal: getDp(18),
        vertical: getDp(24),
      ),
      border: isLastItem
          ? null
          : Border(
              bottom: BorderSide(
              color: aceGrayColor,
              width: getDp(0.5),
            )),
      child: Row(
        children: [
          PressedOpacityButton(
            onPressed: onClickStar,
            child: SvgPicture.asset(
              isSelect
                  ? A.assetsImagesDashboardSelectStar
                  : A.assetsImagesDashboardUnselectStar,
              width: getDp(26),
              height: getDp(26),
              fit: BoxFit.contain,
            ),
          ),
          SizedBox(
            width: getDp(15),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w700,
                    height: 14 / 16,
                  ),
                ),
                Padding(
                  padding: EdgeInsets.only(top: getDp(4)),
                  child: Flex(
                    direction: Axis.horizontal,
                    children: [
                      if (isOverdue)
                        RedTagWidget(
                          content: 'Overdue',
                        ),
                      if (hasCreditBalance)
                        Padding(
                          padding: const EdgeInsets.only(left: 8.0),
                          child: BlueTagWidget(
                            content: 'Credit Available',
                          ),
                        )
                    ],
                  ),
                ),
              ],
            ),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Text(
                amount != '0.00'
                    ? isGet
                        ? S.current.you_ll_get
                        : S.current.you_ll_pay
                    : '',
                style: TextStyle(
                  color: isGet ? aceGreenColor : aceRedColor,
                  fontSize: getSp(12),
                  fontWeight: FontWeight.w400,
                  height: 14 / 12,
                ),
              ),
              SizedBox(
                height: getDp(10),
              ),
              Text(
                amount,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(16),
                  fontWeight: FontWeight.w700,
                  height: 14 / 16,
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}
